home *** CD-ROM | disk | FTP | other *** search
/ Champak 141 / (Vol 141) Oct 17 2011.iso / Games / gamma-bros.swf / scripts / __Packages / classes / shots / ShipBossMissle.as < prev    next >
Encoding:
Text File  |  2011-10-17  |  6.4 KB  |  230 lines

  1. class classes.shots.ShipBossMissle
  2. {
  3.    var x;
  4.    var y;
  5.    var id;
  6.    var dir;
  7.    var speed;
  8.    var color;
  9.    var clip;
  10.    var axis;
  11.    var ac;
  12.    var ep;
  13.    var cv;
  14.    var xMov = 0;
  15.    var yMov = 0;
  16.    var xMovT = 0;
  17.    var yMovT = 0;
  18.    var Name = "shipBossMissle";
  19.    var power = 25;
  20.    var yank = false;
  21.    function ShipBossMissle(px, py, pcolor, pdir, pspeed, pid)
  22.    {
  23.       this.x = px;
  24.       this.y = py;
  25.       this.id = pid;
  26.       this.dir = pdir;
  27.       this.speed = pspeed * 0.66;
  28.       this.color = pcolor;
  29.       _root.d = _root.d + 1;
  30.       this.clip = _root.attachMovie("shipBossMissle","shipBossMissle" + this.id + "Clip",_root.d);
  31.       this.clip._x = this.x;
  32.       this.clip._y = this.y;
  33.       this.clip.id = this.id;
  34.       this.xMov = 0;
  35.       this.yMov = 0;
  36.       if(this.dir == "U")
  37.       {
  38.          this.axis = "y";
  39.          this.yMovT = -1 * this.speed;
  40.          this.xMovT = 0;
  41.       }
  42.       else if(this.dir == "D")
  43.       {
  44.          this.axis = "y";
  45.          this.yMovT = this.speed;
  46.          this.xMovT = 0;
  47.       }
  48.       else if(this.dir == "R")
  49.       {
  50.          this.axis = "x";
  51.          this.yMovT = 0;
  52.          this.xMovT = this.speed;
  53.       }
  54.       else
  55.       {
  56.          this.axis = "x";
  57.          this.yMovT = 0;
  58.          this.xMovT = -1 * this.speed;
  59.       }
  60.       this.clip.color = this.color;
  61.       this.clip.gotoAndStop("fly" + this.dir);
  62.       this.xMovT *= _root.randRange2(0.9,1.1);
  63.       this.yMovT *= _root.randRange2(0.9,1.1);
  64.       this.ac = 0;
  65.       this.ep = _root.randRange(10,30);
  66.       if(this.speed == 12)
  67.       {
  68.          this.cv = 0.5;
  69.       }
  70.       else if(this.speed == 15)
  71.       {
  72.          this.cv = 0.75;
  73.       }
  74.       else
  75.       {
  76.          this.cv = 1;
  77.       }
  78.    }
  79.    function hit()
  80.    {
  81.       var _loc5_ = this.color;
  82.       if(_loc5_ == "Orange")
  83.       {
  84.          _loc5_ = "Red";
  85.       }
  86.       _root.createExploA([this.x + this.clip._width / 2,this.y + this.clip._height / 2,_root.randRange(60,80),_root.randRange(85,100),_loc5_]);
  87.       var _loc3_ = 0;
  88.       var _loc4_ = random(3);
  89.       while(_loc3_ < _loc4_)
  90.       {
  91.          _root.createShrapnel([this.x + this.clip._width / 2,this.y + this.clip._height / 2,"shipBossMissle" + this.color]);
  92.          _loc3_ = _loc3_ + 1;
  93.       }
  94.       _root.powerUp(this.x,this.y,90);
  95.       this.yank = true;
  96.    }
  97.    function bombed()
  98.    {
  99.       var _loc5_ = this.color;
  100.       if(_loc5_ == "Orange")
  101.       {
  102.          _loc5_ = "Red";
  103.       }
  104.       _root.createExploA([this.x + this.clip._width / 2,this.y + this.clip._height / 2,_root.randRange(60,80),_root.randRange(85,100),_loc5_]);
  105.       var _loc3_ = 0;
  106.       var _loc4_ = random(3);
  107.       while(_loc3_ < _loc4_)
  108.       {
  109.          _root.createShrapnel([this.x + this.clip._width / 2,this.y + this.clip._height / 2,"shipBossMissle" + this.color]);
  110.          _loc3_ = _loc3_ + 1;
  111.       }
  112.       _root.powerUp(this.x,this.y,90);
  113.       this.yank = true;
  114.    }
  115.    function main()
  116.    {
  117.       this.ac = this.ac + 1;
  118.       if(this.ac == this.ep)
  119.       {
  120.          var _loc7_ = _root.getAngleRad(this.x,this.y);
  121.          this.xMovT = this.speed * Math.round(Math.cos(_loc7_));
  122.          this.yMovT = this.speed * Math.round(Math.sin(_loc7_));
  123.          if(this.xMovT < -1)
  124.          {
  125.             var _loc8_ = "L";
  126.          }
  127.          else if(this.xMovT > 1)
  128.          {
  129.             _loc8_ = "R";
  130.          }
  131.          else
  132.          {
  133.             _loc8_ = "";
  134.          }
  135.          if(this.yMovT < -1)
  136.          {
  137.             var _loc9_ = "U";
  138.          }
  139.          else if(this.yMovT > 1)
  140.          {
  141.             _loc9_ = "D";
  142.          }
  143.          else
  144.          {
  145.             _loc9_ = "";
  146.          }
  147.          this.clip.gotoAndStop("fly" + _loc8_ + _loc9_);
  148.          this.ac = 0;
  149.          this.ep = _root.randRange(10,30);
  150.       }
  151.       if(this.clip.hitTest(_root[_root.char + "Clip"]))
  152.       {
  153.          _root[_root.char].hit(this.xMov,this.yMov,100,this.power);
  154.          _root.createExploA([this.x + this.clip._width / 2,this.y + this.clip._height / 2,_root.randRange(60,80),_root.randRange(85,100)]);
  155.          _root.audio.playLevel4("missleX" + (random(3) + 1),_root.randRange(15,25));
  156.          var _loc3_ = 0;
  157.          var _loc5_ = random(3);
  158.          while(_loc3_ < _loc5_)
  159.          {
  160.             _root.createShrapnel([this.x + this.clip._width / 2,this.y + this.clip._height / 2,"shipBossMissle" + this.color]);
  161.             _loc3_ = _loc3_ + 1;
  162.          }
  163.          this.yank = true;
  164.       }
  165.       _loc3_ = 0;
  166.       _loc5_ = _root.broShots.length;
  167.       while(_loc3_ < _loc5_)
  168.       {
  169.          var _loc6_ = _root.broShots[_loc3_] + "Clip";
  170.          if(this.clip.hitTest(_root[_loc6_]))
  171.          {
  172.             _root[_root.char].fc = _root[_root.char].fireFreq - _root.rapidVar;
  173.             var _loc4_ = _root.broShots[_loc3_];
  174.             _root[_loc4_].exploX = this.x + this.clip._width / 2;
  175.             _root[_loc4_].exploY = this.y + this.clip._height / 2;
  176.             _root[_loc4_].hit(2);
  177.             _root.createExploA([this.x + this.clip._width / 2,this.y + this.clip._height / 2,_root.randRange(60,80),_root.randRange(85,100)]);
  178.             _root.audio.playLevel4("missleX" + (random(3) + 1),_root.randRange(25,30));
  179.             _loc3_ = 0;
  180.             _loc5_ = random(3);
  181.             while(_loc3_ < _loc5_)
  182.             {
  183.                _root.createShrapnel([this.x + this.clip._width / 2,this.y + this.clip._height / 2,"shipBossMissle" + this.color]);
  184.                _loc3_ = _loc3_ + 1;
  185.             }
  186.             _root.powerUp(this.x,this.y,89);
  187.             this.yank = true;
  188.          }
  189.          _loc3_ = _loc3_ + 1;
  190.       }
  191.       if(this.x > 1050 || this.x < -50 || this.y > 650 || this.y < -50)
  192.       {
  193.          this.yank = true;
  194.       }
  195.       if(this.xMovT < this.xMov)
  196.       {
  197.          this.xMov -= this.cv;
  198.       }
  199.       else if(this.xMovT > this.xMov)
  200.       {
  201.          this.xMov += this.cv;
  202.       }
  203.       else
  204.       {
  205.          this.xMov = this.xMovT;
  206.       }
  207.       if(this.yMovT < this.yMov)
  208.       {
  209.          this.yMov -= this.cv;
  210.       }
  211.       else if(this.yMovT > this.yMov)
  212.       {
  213.          this.yMov += this.cv;
  214.       }
  215.       else
  216.       {
  217.          this.yMov = this.yMovT;
  218.       }
  219.       this.x += this.xMov;
  220.       this.y += this.yMov;
  221.       if(this.yank)
  222.       {
  223.          _root.removeEnemyShot("shipBossMissle" + this.id);
  224.          this.yank = false;
  225.       }
  226.       this.clip._x = this.x;
  227.       this.clip._y = this.y;
  228.    }
  229. }
  230.